package model

import "gin-worked/dao"

type User struct {
	Id         int      `json:"id"`
	Username   string   `gorm:"column(username)" json:"username"`
	Password   string   `gorm:"column(password)" json:"password"`
	Salt       string   `gorm:"column(salt)" json:"salt"`
	Status     int      `gorm:"column(status)" json:"status"`
	Type       int      `gorm:"column(type)" json:"type"`
	CreateTime int      `gorm:"column(create_time)" json:"create_time"`
	UpdateTime int      `gorm:"column(update_time)" json:"update_time"`
	DeleteTime *int     `gorm:"column(delete_time)" json:"delete_time"`
	UserInfo   UserInfo `gorm:"foreignKey:UserId;references:Id"` //
}

func GetUserInfo(data *User, field []string) (User, error) {
	var user User
	err := dao.Db.Select(field).Where(data).Preload("UserInfo").First(&user).Error
	return user, err
}
